#include <iostream>
#include <functional> //bind的申明头文件

///定义一个函数模板，函数指针类型
typedef std::function<void (int, int)> CallbackFun;
class Addition{
public:
    void add(int a, int b)
    {
        std::cout << "Addition::add: " << a+b <<std::endl;
    }
};

void funCaller(CallbackFun p, int a, int b){
    CallbackFun cb = std::move(p);
    cb(a, b);
}

int main(int argc, char* argv[])
{
    Addition b;
    ///使用bind()将对象与普通成员函数隐式的结合在一起
    auto fun = std::bind(&Addition::add, &b, std::placeholders::_1, std::placeholders::_2);
    funCaller(fun, 2, 5);
    return 0;
}
